import { Result, Button } from 'antd';;
import { useRouter } from 'next/router';
// css
import styles from '@/styles/CommonOrder.module.scss';

const PaySuccess = () => {

    const router = useRouter()

    // 再去购买
    const goBuy = function() {
        const { redirect } = router.query;
        if(redirect){
            router.push(redirect);
        }else{
            router.push('/');
        }
    }

    // 随便逛逛
    function goAnyway() {
        const anyway = ['/ticket', '/hotel', '/line', '/car'],
              num = Math.ceil(Math.random()*(anyway.length))-1;
        router.push(anyway[num]);
    }

    return (
        <div className={styles['pay-success']}>
            <Result
                className={styles['pay-result']}
                status="success"
                title="支付成功!"
                subTitle={
                    <>
                        获取更多订单信息，请前往<em onClick={() => { router.push('/personal/order') }}>我的订单</em>
                    </>
                }
                extra={[
                    <Button key="buy" onClick={() => { goBuy() }}>再去购买</Button>,
                    <Button key="buyAny" onClick={() => { goAnyway() }}>随便逛逛</Button>
                ]}
            />
        </div>
    )
}

export default PaySuccess;